import pandas as pd

def check_name_overlap():
    """检查工资表和钉钉表中姓名的重叠情况"""
    
    # 读取工资表
    salary_df = pd.read_excel("d:/pycode/工资表.xlsx")
    salary_names = set(salary_df['姓名'].dropna().astype(str).str.strip())
    
    # 读取钉钉表
    ding_df = pd.read_excel("d:/pycode/ding/宸著锦庭6月考勤.xlsx", skiprows=2)
    ding_names = set(ding_df['Unnamed: 1'].dropna().astype(str).str.strip())
    
    print("工资表中的姓名（前20个）:")
    print("="*50)
    for i, name in enumerate(sorted(salary_names)):
        if i < 20:
            print(f"  {name}")
    print(f"工资表总人数: {len(salary_names)}")
    
    print("\n钉钉表中的姓名:")
    print("="*50)
    for name in sorted(ding_names):
        print(f"  {name}")
    print(f"钉钉表总人数: {len(ding_names)}")
    
    # 检查重叠
    overlap = salary_names.intersection(ding_names)
    print(f"\n重叠的姓名:")
    print("="*50)
    if overlap:
        for name in sorted(overlap):
            print(f"  {name}")
        print(f"重叠人数: {len(overlap)}")
    else:
        print("  没有重叠的姓名")
    
    # 检查相似的姓名（可能有空格或其他差异）
    print("\n检查可能的相似姓名:")
    print("="*50)
    similar_found = False
    for salary_name in salary_names:
        for ding_name in ding_names:
            # 去除空格后比较
            if salary_name.replace(' ', '') == ding_name.replace(' ', ''):
                if salary_name != ding_name:
                    print(f"  相似: '{salary_name}' vs '{ding_name}'")
                    similar_found = True
    
    if not similar_found:
        print("  没有发现相似的姓名")

if __name__ == "__main__":
    check_name_overlap()